

package org.testfire.realm.util;

import org.testfire.realm.converters.StringConverter;

import javax.ejb.Stateless;
import java.util.EnumMap;
import java.util.Map;

/**
 * @author Geoff M. Granum
 * @version 1.0
 */
@Stateless
public class UtilityBean
{

	StringConverter sConvert = new StringConverter();

	/**
	 * For MD5 hashing of passwords.
	 * If this value were to be lost, all of our users would be very, very upset (all accounts would have to be reset).
	 * Not that it matters, but it is as random as my keyboard smashing could make it.
	 */
	public static final String SYSTEM_SALT = "jds723mdfuy4nuyp53miujoisdewjt7ytnr";

	public UtilityBean()
	{
	}

	public String getSalt()
	{
		return SYSTEM_SALT;
	}

	public StringConverter getStringConverter()
	{
		return sConvert;
	}


	public static Map getEnumMap(Class type)
	{
		Object[] ary = type.getEnumConstants();
		Map m = new EnumMap(type);
		for (Object o : ary)
		{
			m.put(o, o);
		}
		return m;
	}


}
